Title: SQL W3S (By-BKK) / 020 Like
Tags: Obsidian_to_Anki

Q: What does the SQL LIKE operator do?
A: It searches for a specified pattern in a column

Q: True/False: LIKE can be used only in the WHERE clause
A: True

Q: Which wildcard in LIKE represents zero, one, or multiple characters?
A: The percent sign %

Q: Which wildcard in LIKE represents a single character?
A: The underscore _

Q: How do you select all customers whose names start with "a"?
A: SELECT * FROM Customers WHERE CustomerName LIKE 'a%'

Q: Reverse card:
SELECT * FROM Customers WHERE CustomerName LIKE 'a%'
A: How do you find customers whose names start with 'a'?

Q: How do you select records where city starts with "L", then any one character, then "nd", then two more characters?
A: SELECT * FROM Customers WHERE city LIKE 'L_nd__'

Q: What does the LIKE pattern '%L%' find?
A: Rows where the value contains the letter 'L'

Q: How do you select customers whose names end with "a"?
A: SELECT * FROM Customers WHERE CustomerName LIKE '%a'

Q: How do you find customers whose names start with "La"?
A: SELECT * FROM Customers WHERE CustomerName LIKE 'La%'

Q: True/False: You can combine conditions with LIKE using AND or OR
A: True

Q: Reverse card:
SELECT * FROM Customers WHERE CustomerName LIKE 'a%' OR CustomerName LIKE 'b%'
A: How do you find customers whose names start with 'a' or 'b'?

Q: What does the LIKE pattern 'b%s' find?
A: Names starting with 'b' and ending with 's'

Q: How do you select customers whose names contain "or"?
A: SELECT * FROM Customers WHERE CustomerName LIKE '%or%'

Q: How do you find customers whose names have "r" as the second character?
A: SELECT * FROM Customers WHERE CustomerName LIKE '_r%'

Q: Reverse card:
The underscore _ wildcard
A: Which symbol in LIKE matches exactly one character?

Q: What does the LIKE pattern 'a__%' return?
A: Names starting with 'a' and have at least 3 characters

Q: Without wildcards, what does LIKE do?
A: It matches rows with exact value

Q: True/False: LIKE works with both % and _ wildcards
A: True

Q: SELECT * FROM Customers WHERE CustomerName LIKE 'a%' OR CustomerName LIKE 'b%'
A: How do you find customers whose names start with 'a' or 'b'?

Q: How do you select customers from Spain using LIKE?
A: SELECT * FROM Customers WHERE Country LIKE 'Spain'